package com.ruoyi.supply.enums;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;

/**
 * @author huangxiong
 * @date 2025/06/02 21:25
 */
@Getter
public enum MemberGradeEnum {

    /**
     * 月会员
     * 季度会员
     * 年会员
     */
    //游客
    TOURIST("0","普通用户",0),
    MONTH("1","月会员",1),
    QUARTER("2","季度会员",3),
    YEAR("3","年会员",12);

    private final String type;
    private final String desc;
    private final Integer month;

    MemberGradeEnum(String type, String desc,Integer month) {
        this.type = type;
        this.desc = desc;
        this.month = month;
    }
     public static MemberGradeEnum getByCode(String code) {
         for (MemberGradeEnum value : MemberGradeEnum.values()) {
            if (value.getType().equals(code)) {
                return value;
            }
        }
         return null;
     }
     public String max(String code){
        if(StrUtil.isBlank(code) || !NumberUtil.isNumber(code)){
            return this.type;
        }
        return String.valueOf(NumberUtil.max(Integer.parseInt(this.type),Integer.parseInt(code)));

     }
}
